package com.lanou.renrenxin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou.renrenxin.R;
import com.lanou.renrenxin.data.ContactBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zy on 16/3/3.
 */
public class ContackListAdapter extends BaseAdapter {
    private ArrayList<ContactBean> contactBeans;
    private Context context;
    private List<String> data;

    public ContackListAdapter(Context context) {
        this.context = context;
    }

    public void initData(List<String> username) {
        this.data = username;
    }

    @Override
    public int getCount() {

        return null == data ? 0 : data.size();


    }

    @Override
    public Object getItem(int position) {

        return null ;

    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_contactlist, null);
            viewHolder = new ViewHolder();
            viewHolder.nicknameTv = (TextView) convertView.findViewById(R.id.contactitem_user_nickname);
            viewHolder.userphotoIV = (ImageView) convertView.findViewById(R.id.contactitem_user_iv);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if (data != null) {
            viewHolder.nicknameTv.setText(data.get(position));
//            viewHolder.userphotoIV.setImageResource(contactBean.getImageid());
        }
        return convertView;
    }

    class ViewHolder {
        private TextView nicknameTv;
        private ImageView userphotoIV;
    }
}
